<template>
  <section class="comp-main-container">
    <div class="layer-rooms">
      <div class="room room-0"
        v-show="roomData[0].key">
        <div class="room-image"
          :class="[roomData[0].rotate && ('rotate-' + roomData[0].rotate), 'room-' + roomData[0].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[0].key }}</div> -->
      </div>
      <div class="room room-1"
        v-show="roomData[1].key">
        <div class="room-image"
          :class="[roomData[1].rotate && ('rotate-' + roomData[1].rotate), 'room-' + roomData[1].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[1].key }}</div> -->
      </div>
      <div class="room room-2"
        v-show="roomData[2].key">
        <div class="room-image"
          :class="[roomData[2].rotate && ('rotate-' + roomData[2].rotate), 'room-' + roomData[2].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[2].key }}</div> -->
      </div>

      <div class="room room-3"
        v-show="roomData[3].key">
        <div class="room-image"
          :class="[roomData[3].rotate && ('rotate-' + roomData[3].rotate), 'room-' + roomData[3].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[3].key }}</div> -->
      </div>
      <div class="room center-room"
        v-show="roomData[4].key">
        <div class="room-image"
          :class="[roomData[4].rotate && ('rotate-' + roomData[4].rotate), 'room-' + roomData[4].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[4].key }}</div> -->
        <div class="player"
          :class="[playerChar]"></div>
        <!-- <img class="player"
          :src="playerChar" alt=""> -->
      </div>
      <div class="room room-5"
        v-show="roomData[5].key">
        <div class="room-image"
          :class="[roomData[5].rotate && ('rotate-' + roomData[5].rotate), 'room-' + roomData[5].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[5].key }}</div> -->
      </div>

      <div class="room room-6"
        v-show="roomData[6].key">
        <div class="room-image"
          :class="[roomData[6].rotate && ('rotate-' + roomData[6].rotate), 'room-' + roomData[6].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[6].key }}</div> -->
      </div>
      <div class="room room-7"
        v-show="roomData[7].key">
        <div class="room-image"
          :class="[roomData[7].rotate && ('rotate-' + roomData[7].rotate), 'room-' + roomData[7].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[7].key }}</div> -->
      </div>
      <div class="room room-8"
        v-show="roomData[8].key">
        <div class="room-image"
          :class="[roomData[8].rotate && ('rotate-' + roomData[8].rotate), 'room-' + roomData[8].image]"
        ></div>
        <!-- <div class="room-info">{{ roomData[8].key }}</div> -->
      </div>
    </div>
  </section>
</template>

<script>
import player from '@/models/Player'

export default {
  props: {
    roomData: {
      type: Array,
      required: true
    }
  },

  data () {
    return {
      player
    }
  },

  computed: {
    playerChar () {
      if (this.player.character) {
        return 'char-' + this.player.character
      } else {
        return ''
      }
    }
  }
}
</script>

<style scoped lang="less">
.comp-main-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
  overflow: hidden;
  .layer-rooms {
    position: absolute;
    z-index: 1;
    left: calc((100% - 900px - 16px) / 2);
    top: calc((100% - 900px - 16px) / 2);
    width: 916px;
    height: 916px;
    overflow: hidden;
  }
  .room {
    position: absolute;
    z-index: 2;
    .room-image {
      width: 300px;
      height: 300px;
      // transition: all 0.3s;
    }
    .room-info {
      position: absolute;
      z-index: 3;
      right: 12px;
      bottom: 12px;
    }
    .player {
      position: absolute;
      z-index: 4;
      left: 115px;
      top: 115px;
      width: 70px;
      height: 70px;
      border-radius: 100%;
      border: 6px solid red;
      box-shadow: 4px 4px 12px #494949;
    }
  }
  .room-0 {
    left: 0;
    top: 0;
  }
  .room-1 {
    left: 308px;
    top: 0;
  }
  .room-2 {
    left: 616px;
    top: 0;
  }
  .room-3 {
    left: 0;
    top: 308px;
  }
  .center-room {
    left: 308px;
    top: 308px;
  }
  .room-5 {
    left: 616px;
    top: 308px;
  }
  .room-6 {
    left: 0;
    top: 616px;
  }
  .room-7 {
    left: 308px;
    top: 616px;
  }
  .room-8 {
    left: 616px;
    top: 616px;
  }
  .rotate-90 {
    transform: rotate(90deg);
  }
  .rotate-180 {
    transform: rotate(180deg);
  }
  .rotate-270 {
    transform: rotate(270deg);
  }
}
</style>
